package com.order.web;

import javax.servlet.*;
import javax.servlet.http.*;

import com.order.dao.bean.Seat;

import java.util.*;
import java.io.*;
public class SeatServlet extends HttpServlet
{
	public void doGet(HttpServletRequest req,HttpServletResponse resp)
                    throws ServletException,IOException
                    {
                    	doPost(req,resp);
                    }
      
    public void doPost(HttpServletRequest req,HttpServletResponse resp)
                     throws ServletException,IOException   
                     {
                     	    Seat seat=new Seat();
                     		resp.setContentType("text/html;charset=gbk");
                     		req.setCharacterEncoding("gbk");
                        	String action=req.getParameter("test");
                     		System.out.println(action);
                     		 if(action.equals("inita"))
                     		{
                     			String seatx=req.getParameter("seatcountx");
                     			String seaty=req.getParameter("seatcounty");
                     			System.out.print(seatx+seaty);
                     			seat.initseata(seatx,seaty);
                     			this.forward("canweiset.jsp",req,resp);
                     		}
                     		 else if(action.equals("initb"))
                     		{
                     		    String s=req.getParameter("seatcountxx");
                     		    System.out.println(s);
                     			seat.initseatb(s);
                     			System.out.print("=========");
                     			this.forward("canweiset.jsp",req,resp);
                     		}
                     		else if(action.equals("add"))
                     		{
                     			String xb=req.getParameter("xb");
                     			System.out.println(xb);
                     			seat.addseat(xb);
                     			this.forward("canweiset.jsp", req, resp);
                     		}
                     		else if(action.equals("del"))
                     		{
                     			String xb=req.getParameter("xb");
                     			String seatno=req.getParameter("seatno");
                     			seat.delseat(xb, seatno);
                     			this.forward("canweiset.jsp", req, resp);
                     		}
                     } 
                       public void forward(String path,HttpServletRequest req,
                      HttpServletResponse resp)
               throws ServletException,
                      IOException
                      {
                      	req.getRequestDispatcher("/"+path).include(req,resp);
                      }            
}